#include <stdio.h>
#include <string.h>
#include <stdlib.h>

static long string_hash(register unsigned char *p, int size) {
    register int len;
    register long x;

    len = size;
    x = *p << 7;
    while (--len >= 0) {
        x = (1000003*x) ^ *p++;
    }

    x ^= size;

    return x;
}


static unsigned char cache_bits[1 << 29];
static int bit_mask(unsigned long x) {
    int bit = 0;
    int byte = 0;
    int mask = 0;
    int rv = 1;

    x -= 1;
    bit = 7 - (x % 8);
    x >>= 3;

    byte = cache_bits[x];
    bit = 1 << bit;
    if (!(byte & bit)) {
        rv = 0;
        byte |= bit;
        cache_bits[x] = byte;
    }

    return rv;
}


int main(int argc, char **argv) {
    unsigned char *ch;
    unsigned long i = 0,
                  x = 0,
                  n = 0xFFFFFFFF;

    for (; i < n; i++) {
        x = string_hash((unsigned char *)&i, 4);

        if (bit_mask(x)) {
            ch = (unsigned char *)&i;
            printf("%c%c%c%c\n", ch[0], ch[1], ch[2], ch[3]);
        }
    }

    return 0;
}


